﻿using System.Web.Mvc;

namespace cludg.Web.Core.RenderHelpers
{
	public static class LongTextRenderHelper
	{
		public static MvcHtmlString TrimLongText(this HtmlHelper html, string text, int maxLength)
		{
			var needTrim = text.Length > maxLength;

			return MvcHtmlString.Create(text.Substring(0, needTrim ? maxLength : text.Length) 
				+ (needTrim ? "..." : string.Empty));
		}
	}
}